package nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/8 0008.
 */
public class AllCart implements Parcelable {
    public String unitId;
    public int type;
    public String title = "";
    public float money;
    public float one_money;
    public String image="";
    public String desc = "";
    public List<HomeItemCart> itemList;
    public boolean isSelect;
    public int number;
    public int orderType;
    public int weight;
    public float getOnePiece(){
        return one_money/weight;
    }

    public int getTotalWeight(){
        return number*weight;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.unitId);
        dest.writeInt(this.type);
        dest.writeString(this.title);
        dest.writeFloat(this.money);
        dest.writeFloat(this.one_money);
        dest.writeString(this.image);
        dest.writeString(this.desc);
        dest.writeList(this.itemList);
        dest.writeByte(this.isSelect ? (byte) 1 : (byte) 0);
        dest.writeInt(this.number);
        dest.writeInt(this.orderType);
        dest.writeInt(this.weight);
    }

    public AllCart() {
    }

    protected AllCart(Parcel in) {
        this.unitId = in.readString();
        this.type = in.readInt();
        this.title = in.readString();
        this.money = in.readFloat();
        this.one_money = in.readFloat();
        this.image = in.readString();
        this.desc = in.readString();
        this.itemList = new ArrayList<HomeItemCart>();
        in.readList(this.itemList, HomeItemCart.class.getClassLoader());
        this.isSelect = in.readByte() != 0;
        this.number = in.readInt();
        this.orderType = in.readInt();
        this.weight = in.readInt();
    }

    public static final Parcelable.Creator<AllCart> CREATOR = new Parcelable.Creator<AllCart>() {
        @Override
        public AllCart createFromParcel(Parcel source) {
            return new AllCart(source);
        }

        @Override
        public AllCart[] newArray(int size) {
            return new AllCart[size];
        }
    };
}
